package com.campuscrowdsourcing.server.service.impl;

import com.campuscrowdsourcing.server.domain.entity.Team;
import com.campuscrowdsourcing.server.domain.vo.TeamVO;
import com.campuscrowdsourcing.server.mapper.TeamMapper;
import com.campuscrowdsourcing.server.mapper.TaskMapper;
import com.campuscrowdsourcing.server.service.TeamService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 团队信息	提示：	money、score自动填充0 服务实现类
 * </p>
 *
 * @author Xinyuan Zhao
 * @since 2023-03-15
 */
@Service
public class TeamServiceImpl extends ServiceImpl<TeamMapper, Team> implements TeamService {
    @Resource
    TeamMapper TeamMapper;
    @Resource
    TaskMapper TaskMapper;

    @Override
    public long findteamCount(Integer id) {
        return TeamMapper.findteamCount(id);
    }

    @Override
    public Object findOnePlus(Integer id) {
        TeamVO TeamVO = new TeamVO();
        BeanUtils.copyProperties(getById(id),TeamVO);
        TeamVO.setMember((int) findteamCount(id));
        TeamVO.setTask((int) TaskMapper.findTeamCount(id));
        return TeamVO;
    }
}
